package com.wanbatv.wangwangba.model.imple;

import android.content.Context;

import com.wanbatv.wangwangba.model.EncyclopediasModel;
import com.wanbatv.wangwangba.model.OnEncyclopediasListener;
import com.wanbatv.wangwangba.model.entity.EncyclopediasContentData;
import com.wanbatv.wangwangba.util.Config;
import com.wanbatv.wangwangba.util.GitEncyclopediasService;
import com.wanbatv.wangwangba.util.HeaderClient;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by 俞亚楠 on 2016/7/28.
 */
public class EncyclopediasModelImple implements EncyclopediasModel {
    private Context context;
    public EncyclopediasModelImple(Context context){
        this.context=context;
    }

    Retrofit retrofit=new Retrofit.Builder()
            .baseUrl(Config.httpUrl())
            .addConverterFactory(GsonConverterFactory.create())
            .client(HeaderClient.genericClient())
            .build();
    GitEncyclopediasService api=retrofit.create(GitEncyclopediasService.class);
    @Override
    public void setLoadEncyclopediasContentData(final OnEncyclopediasListener onEncyclopediasListener, String token) {
        api.getEncyclopediasContent(token).enqueue(new Callback<EncyclopediasContentData>() {
            @Override
            public void onResponse(Call<EncyclopediasContentData> call, Response<EncyclopediasContentData> response) {
//                onEncyclopediasListener.onLoadEncyclopediasContentData();
            }

            @Override
            public void onFailure(Call<EncyclopediasContentData> call, Throwable t) {

            }
        });
    }
}
